package util;

public class ImageCursor {
	/*
	 * Step variables.
	 * 0, UP, 0, DOWN, LEFT, UPLEFT, DOWNLEFT, RIGHT, UPRIGHT, DOWNRIGHT
	 * Default as UP_DECENDED and LEFT_DECENDED
	 */
	protected int[] dx
		= {0,  0, 0, 0, -1, -1, -1, 1, -1, 1};
	protected int[] dy 
		= {0, -1, 1, 0,  0, -1,  1, 0,  1, 1};
	public static final int UP 				= 1;
	public static final int DOWN 			= 2;
	public static final int LEFT 			= 4;
	public static final int RIGHT 			= 7;
	
	public static final int UPLEFT 			= UP + LEFT;		// 5 
	public static final int DOWNLEFT 		= DOWN + LEFT;		// 6 
	public static final int UPRIGHT		 	= UP + RIGHT;		// 8
	public static final int DOWNRIGHT	 	= DOWN + RIGHT;		// 9
	
	/*
	 * Direction 
	 */
	private int xdirection, ydirection;
	public static final int UP_DECENDED		= 1;
	public static final int DOWN_DECENDED	= -1;
	public static final int LEFT_DECENDED	= 1;
	public static final int RIGHT_DECENDED	= -1;
	
	private int x;
	private int y;
	
	public ImageCursor() {
		this.setXDirection(LEFT_DECENDED);
		this.setYDirection(UP_DECENDED);
		
		this.setX(0);
		this.setY(0);
	}
	
	public ImageCursor(int x, int y) {
		this.setXDirection(LEFT_DECENDED);
		this.setYDirection(UP_DECENDED);
		
		this.setX(x);
		this.setY(y);
	}
	
	public ImageCursor(int x, int y, int xdir, int ydir) {
		this.setXDirection(xdir);
		this.setYDirection(ydir);
		
		this.setX(x);
		this.setY(y);
	}
	
	/**
	 * 
	 * @param dx
	 * @param dy
	 */
	public void move(int dx, int dy) {
		this.setX(this.getX() + dx);
		this.setY(this.getY() + dy);
	}
	
	/**
	 * 
	 * @param dir
	 */
	public void move(int dir) {
		this.move(dx[dir] * xdirection, dy[dir] * ydirection);
	}
	
	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}
	/**
	 * @param x the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}
	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}
	/**
	 * @param y the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}
	/**
	 * @return the direction
	 */
	public int getXDirection() {
		return xdirection;
	}
	/**
	 * @param direction the direction to set
	 */
	public void setXDirection(int direction) {
		this.xdirection = direction;
	}
	/**
	 * @return the ydirection
	 */
	public int getYDirection() {
		return ydirection;
	}
	/**
	 * @param ydirection the ydirection to set
	 */
	public void setYDirection(int ydirection) {
		this.ydirection = ydirection;
	}
}
